/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('tingwu', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CreateTaskRequest {
  appKey?: string(name='AppKey', example='JV1sRTisRMi****'),
  input?: {
    audioChannelMode?: string(name='AudioChannelMode'),
    fileUrl?: string(name='FileUrl', example='http://xxx.com/zzz/1.wav'),
    format?: string(name='Format', example='pcm'),
    languageHints?: [ string ](name='LanguageHints'),
    multipleStreamsEnabled?: boolean(name='MultipleStreamsEnabled'),
    outputPath?: string(name='OutputPath'),
    progressiveCallbacksEnabled?: boolean(name='ProgressiveCallbacksEnabled'),
    sampleRate?: int32(name='SampleRate', example='16000'),
    sourceLanguage?: string(name='SourceLanguage', description='This parameter is required.', example='cn'),
    taskId?: string(name='TaskId'),
    taskKey?: string(name='TaskKey', example='task_tingwu_123'),
  }(name='Input'),
  parameters?: {
    autoChaptersEnabled?: boolean(name='AutoChaptersEnabled', example='true'),
    contentExtraction?: {
      extractionContents?: [ 
        {
          content?: string(name='Content'),
          identity?: string(name='Identity'),
          title?: string(name='Title'),
        }
      ](name='ExtractionContents'),
      sceneIntroduction?: string(name='SceneIntroduction'),
      speakerMap?: map[string]any(name='SpeakerMap'),
    }(name='ContentExtraction'),
    contentExtractionEnabled?: boolean(name='ContentExtractionEnabled'),
    customPrompt?: {
      contents?: [ 
        {
          model?: string(name='Model'),
          name?: string(name='Name', description='This parameter is required.'),
          prompt?: string(name='Prompt', description='This parameter is required.'),
          transType?: string(name='TransType'),
        }
      ](name='Contents'),
    }(name='CustomPrompt'),
    customPromptEnabled?: boolean(name='CustomPromptEnabled'),
    extraParams?: {
      domainEducationEnabled?: boolean(name='DomainEducationEnabled'),
      maxKeywords?: int32(name='MaxKeywords'),
      nfixEnabled?: boolean(name='NfixEnabled'),
      ocrAuxiliaryEnabled?: boolean(name='OcrAuxiliaryEnabled'),
      translateLlmSceneEnabled?: boolean(name='TranslateLlmSceneEnabled'),
    }(name='ExtraParams'),
    identityRecognition?: {
      identityContents?: [ 
        {
          description?: string(name='Description'),
          name?: string(name='Name'),
        }
      ](name='IdentityContents'),
      sceneIntroduction?: string(name='SceneIntroduction'),
    }(name='IdentityRecognition'),
    identityRecognitionEnabled?: boolean(name='IdentityRecognitionEnabled'),
    meetingAssistance?: {
      types?: [ string ](name='Types'),
    }(name='MeetingAssistance'),
    meetingAssistanceEnabled?: boolean(name='MeetingAssistanceEnabled', example='false'),
    pptExtractionEnabled?: boolean(name='PptExtractionEnabled'),
    serviceInspection?: {
      inspectionContents?: [ 
        {
          content?: string(name='Content'),
          title?: string(name='Title'),
        }
      ](name='InspectionContents'),
      inspectionIntroduction?: string(name='InspectionIntroduction'),
      sceneIntroduction?: string(name='SceneIntroduction'),
      speakerMap?: map[string]any(name='SpeakerMap'),
    }(name='ServiceInspection'),
    serviceInspectionEnabled?: boolean(name='ServiceInspectionEnabled'),
    summarization?: {
      types?: [ string ](name='Types', example='Paragraph'),
    }(name='Summarization'),
    summarizationEnabled?: boolean(name='SummarizationEnabled', example='false'),
    textPolishEnabled?: boolean(name='TextPolishEnabled'),
    transcoding?: {
      spectrumEnabled?: boolean(name='SpectrumEnabled', example='false'),
      targetAudioFormat?: string(name='TargetAudioFormat', example='mp3'),
      targetVideoFormat?: string(name='TargetVideoFormat', example='mp4'),
      videoThumbnailEnabled?: boolean(name='VideoThumbnailEnabled', example='false'),
    }(name='Transcoding'),
    transcription?: {
      additionalStreamOutputLevel?: int32(name='AdditionalStreamOutputLevel'),
      audioEventDetectionEnabled?: boolean(name='AudioEventDetectionEnabled', example='false'),
      diarization?: {
        speakerCount?: int32(name='SpeakerCount', example='2'),
      }(name='Diarization'),
      diarizationEnabled?: boolean(name='DiarizationEnabled', example='false'),
      model?: string(name='Model'),
      outputLevel?: int32(name='OutputLevel'),
      phraseId?: string(name='PhraseId'),
      realtimeDiarizationEnabled?: boolean(name='RealtimeDiarizationEnabled'),
    }(name='Transcription'),
    translation?: {
      additionalStreamOutputLevel?: int32(name='AdditionalStreamOutputLevel'),
      outputLevel?: int32(name='OutputLevel'),
      targetLanguages?: [ string ](name='TargetLanguages'),
    }(name='Translation'),
    translationEnabled?: boolean(name='TranslationEnabled', example='false'),
  }(name='Parameters'),
  operation?: string(name='operation', example='stop'),
  type?: string(name='type', description='This parameter is required.', example='offline'),
}

model CreateTaskResponseBody = {
  code?: string(name='Code', example='0'),
  data?: {
    meetingJoinUrl?: string(name='MeetingJoinUrl'),
    taskId?: string(name='TaskId', example='c5394c6ee0fb474899d42215a3925c7e'),
    taskKey?: string(name='TaskKey', example='task_tingwu_123'),
    taskStatus?: string(name='TaskStatus'),
  }(name='Data'),
  message?: string(name='Message', example='Success.'),
  requestId?: string(name='RequestId', example='35124E1C-AE99-5D6C-A52E-BD689D8D****'),
}

model CreateTaskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateTaskResponseBody(name='body'),
}

/**
 * @summary 创建听悟任务
 *
 * @param request CreateTaskRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateTaskResponse
 */
async function createTaskWithOptions(request: CreateTaskRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateTaskResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.operation)) {
    query['operation'] = request.operation;
  }
  if (!Util.isUnset(request.type)) {
    query['type'] = request.type;
  }

  var body : map[string]any = {};
  if (!Util.isUnset(request.appKey)) {
    body['AppKey'] = request.appKey;
  }
  if (!Util.isUnset(request.input)) {
    body['Input'] = request.input;
  }
  if (!Util.isUnset(request.parameters)) {
    body['Parameters'] = request.parameters;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateTask',
    version = '2023-09-30',
    protocol = 'HTTPS',
    pathname = `/openapi/tingwu/v2/tasks`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 创建听悟任务
 *
 * @param request CreateTaskRequest
 * @return CreateTaskResponse
 */
async function createTask(request: CreateTaskRequest): CreateTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createTaskWithOptions(request, headers, runtime);
}

model CreateTranscriptionPhrasesRequest {
  description?: string(name='Description', example='custom fruit phrases list'),
  name?: string(name='Name', description='This parameter is required.', example='fruit_phrase'),
  wordWeights?: string(name='WordWeights', description='This parameter is required.', example='{"苹果":3,"西瓜":3}'),
}

model CreateTranscriptionPhrasesResponseBody = {
  code?: string(name='Code', example='0'),
  data?: {
    errorCode?: string(name='ErrorCode', example='0'),
    errorMessage?: string(name='ErrorMessage', example='success'),
    phraseId?: string(name='PhraseId', example='a93b91141c0f422fa114af203f8b****'),
    status?: string(name='Status', example='SUCCEEDED'),
  }(name='Data'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', description='Id of the request', example='35124E1C-AE99-5D6C-A52E-BD689D8D****'),
}

model CreateTranscriptionPhrasesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateTranscriptionPhrasesResponseBody(name='body'),
}

/**
 * @summary 创建热词词表
 *
 * @param request CreateTranscriptionPhrasesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateTranscriptionPhrasesResponse
 */
async function createTranscriptionPhrasesWithOptions(request: CreateTranscriptionPhrasesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateTranscriptionPhrasesResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.description)) {
    body['Description'] = request.description;
  }
  if (!Util.isUnset(request.name)) {
    body['Name'] = request.name;
  }
  if (!Util.isUnset(request.wordWeights)) {
    body['WordWeights'] = request.wordWeights;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateTranscriptionPhrases',
    version = '2023-09-30',
    protocol = 'HTTPS',
    pathname = `/openapi/tingwu/v2/resources/phrases`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 创建热词词表
 *
 * @param request CreateTranscriptionPhrasesRequest
 * @return CreateTranscriptionPhrasesResponse
 */
async function createTranscriptionPhrases(request: CreateTranscriptionPhrasesRequest): CreateTranscriptionPhrasesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createTranscriptionPhrasesWithOptions(request, headers, runtime);
}

model DeleteTranscriptionPhrasesResponseBody = {
  data?: {
    errorCode?: string(name='ErrorCode'),
    errorMessage?: string(name='ErrorMessage'),
    status?: string(name='Status'),
  }(name='Data'),
  errorCode?: string(name='ErrorCode', example='0'),
  errorMessage?: string(name='ErrorMessage', example='success'),
  status?: string(name='Status', example='SUCCEEDED'),
}

model DeleteTranscriptionPhrasesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteTranscriptionPhrasesResponseBody(name='body'),
}

/**
 * @summary 删除词表
 *
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteTranscriptionPhrasesResponse
 */
async function deleteTranscriptionPhrasesWithOptions(PhraseId: string, headers: map[string]string, runtime: Util.RuntimeOptions): DeleteTranscriptionPhrasesResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'DeleteTranscriptionPhrases',
    version = '2023-09-30',
    protocol = 'HTTPS',
    pathname = `/openapi/tingwu/v2/resources/phrases/${OpenApiUtil.getEncodeParam(PhraseId)}`,
    method = 'DELETE',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 删除词表
 *
 * @return DeleteTranscriptionPhrasesResponse
 */
async function deleteTranscriptionPhrases(PhraseId: string): DeleteTranscriptionPhrasesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteTranscriptionPhrasesWithOptions(PhraseId, headers, runtime);
}

model GetTaskInfoResponseBody = {
  code?: string(name='Code', example='0'),
  data?: {
    errorCode?: string(name='ErrorCode'),
    errorMessage?: string(name='ErrorMessage'),
    outputMp3Path?: string(name='OutputMp3Path'),
    outputMp4Path?: string(name='OutputMp4Path'),
    outputSpectrumPath?: string(name='OutputSpectrumPath'),
    outputThumbnailPath?: string(name='OutputThumbnailPath'),
    result?: {
      autoChapters?: string(name='AutoChapters'),
      contentExtraction?: string(name='ContentExtraction'),
      customPrompt?: string(name='CustomPrompt'),
      identityRecognition?: string(name='IdentityRecognition'),
      meetingAssistance?: string(name='MeetingAssistance'),
      pptExtraction?: string(name='PptExtraction'),
      serviceInspection?: string(name='ServiceInspection'),
      summarization?: string(name='Summarization'),
      textPolish?: string(name='TextPolish'),
      transcription?: string(name='Transcription'),
      translation?: string(name='Translation'),
    }(name='Result'),
    taskId?: string(name='TaskId', example='c5394c6ee0fb474899d42215a3925c7e'),
    taskKey?: string(name='TaskKey', example='task_tingwu_123'),
    taskStatus?: string(name='TaskStatus', example='COMPLETE'),
  }(name='Data'),
  message?: string(name='Message', example='Success.'),
  requestId?: string(name='RequestId', example='35124E1C-AE99-5D6C-A52E-BD689D8D****'),
}

model GetTaskInfoResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetTaskInfoResponseBody(name='body'),
}

/**
 * @summary 查询听悟任务信息
 *
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetTaskInfoResponse
 */
async function getTaskInfoWithOptions(TaskId: string, headers: map[string]string, runtime: Util.RuntimeOptions): GetTaskInfoResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetTaskInfo',
    version = '2023-09-30',
    protocol = 'HTTPS',
    pathname = `/openapi/tingwu/v2/tasks/${OpenApiUtil.getEncodeParam(TaskId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 查询听悟任务信息
 *
 * @return GetTaskInfoResponse
 */
async function getTaskInfo(TaskId: string): GetTaskInfoResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getTaskInfoWithOptions(TaskId, headers, runtime);
}

model GetTranscriptionPhrasesResponseBody = {
  code?: string(name='Code', example='0'),
  data?: {
    errorCode?: string(name='ErrorCode', example='0'),
    errorMessage?: string(name='ErrorMessage', example='success'),
    phrases?: [ 
      {
        description?: string(name='Description', example='custom fruit phrases list'),
        name?: string(name='Name', example='fruit_phrase'),
        phraseId?: string(name='PhraseId', example='a93b91141c0f422fa114af203f8b****'),
        wordWeights?: string(name='WordWeights', example='{"苹果":3,"西瓜":3}'),
      }
    ](name='Phrases'),
    status?: string(name='Status', example='SUCCEEDED'),
  }(name='Data'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', description='Id of the request', example='35124E1C-AE99-5D6C-A52E-BD689D8D****'),
}

model GetTranscriptionPhrasesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetTranscriptionPhrasesResponseBody(name='body'),
}

/**
 * @summary 查询热词词表信息
 *
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetTranscriptionPhrasesResponse
 */
async function getTranscriptionPhrasesWithOptions(PhraseId: string, headers: map[string]string, runtime: Util.RuntimeOptions): GetTranscriptionPhrasesResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetTranscriptionPhrases',
    version = '2023-09-30',
    protocol = 'HTTPS',
    pathname = `/openapi/tingwu/v2/resources/phrases/${OpenApiUtil.getEncodeParam(PhraseId)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 查询热词词表信息
 *
 * @return GetTranscriptionPhrasesResponse
 */
async function getTranscriptionPhrases(PhraseId: string): GetTranscriptionPhrasesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getTranscriptionPhrasesWithOptions(PhraseId, headers, runtime);
}

model ListTranscriptionPhrasesResponseBody = {
  code?: string(name='Code', example='0'),
  data?: {
    errorCode?: string(name='ErrorCode', example='PHS.Exceed'),
    errorMessage?: string(name='ErrorMessage', example='The num of the phrase exceeds the upper limit.'),
    phrases?: [ 
      {
        description?: string(name='Description', example='custom fruit phrases list'),
        name?: string(name='Name', example='fruit_phrase'),
        phraseId?: string(name='PhraseId', example='a93b91141c0f422fa114af203f8b****'),
      }
    ](name='Phrases'),
    status?: string(name='Status', example='SUCCEEDED'),
  }(name='Data'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', description='Id of the request', example='35124E1C-AE99-5D6C-A52E-BD689D8D****'),
}

model ListTranscriptionPhrasesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListTranscriptionPhrasesResponseBody(name='body'),
}

/**
 * @summary 列举用户所有热词词表信息
 *
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListTranscriptionPhrasesResponse
 */
async function listTranscriptionPhrasesWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): ListTranscriptionPhrasesResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'ListTranscriptionPhrases',
    version = '2023-09-30',
    protocol = 'HTTPS',
    pathname = `/openapi/tingwu/v2/resources/phrases`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 列举用户所有热词词表信息
 *
 * @return ListTranscriptionPhrasesResponse
 */
async function listTranscriptionPhrases(): ListTranscriptionPhrasesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listTranscriptionPhrasesWithOptions(headers, runtime);
}

model UpdateTranscriptionPhrasesRequest {
  description?: string(name='Description', example='custom fruit phrases list'),
  name?: string(name='Name', description='This parameter is required.', example='fruit_phrase'),
  wordWeights?: string(name='WordWeights', description='This parameter is required.', example='{"苹果":3,"西瓜":3}'),
}

model UpdateTranscriptionPhrasesResponseBody = {
  code?: string(name='Code', example='0'),
  data?: {
    errorCode?: string(name='ErrorCode', example='0'),
    errorMessage?: string(name='ErrorMessage', example='success'),
    status?: string(name='Status', example='SUCCEEDED'),
  }(name='Data'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', description='Id of the request', example='35124E1C-AE99-5D6C-A52E-BD689D8D****'),
}

model UpdateTranscriptionPhrasesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateTranscriptionPhrasesResponseBody(name='body'),
}

/**
 * @summary 更新热词词表
 *
 * @param request UpdateTranscriptionPhrasesRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateTranscriptionPhrasesResponse
 */
async function updateTranscriptionPhrasesWithOptions(PhraseId: string, request: UpdateTranscriptionPhrasesRequest, headers: map[string]string, runtime: Util.RuntimeOptions): UpdateTranscriptionPhrasesResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.description)) {
    body['Description'] = request.description;
  }
  if (!Util.isUnset(request.name)) {
    body['Name'] = request.name;
  }
  if (!Util.isUnset(request.wordWeights)) {
    body['WordWeights'] = request.wordWeights;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'UpdateTranscriptionPhrases',
    version = '2023-09-30',
    protocol = 'HTTPS',
    pathname = `/openapi/tingwu/v2/resources/phrases/${OpenApiUtil.getEncodeParam(PhraseId)}`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 更新热词词表
 *
 * @param request UpdateTranscriptionPhrasesRequest
 * @return UpdateTranscriptionPhrasesResponse
 */
async function updateTranscriptionPhrases(PhraseId: string, request: UpdateTranscriptionPhrasesRequest): UpdateTranscriptionPhrasesResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return updateTranscriptionPhrasesWithOptions(PhraseId, request, headers, runtime);
}

